package net.mgsx.product.t2m.modisco;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmt.modisco.infra.query.core.exception.ModelQueryExecutionException;
import org.eclipse.gmt.modisco.infra.query.core.java.IJavaModelQuery;
import org.junit.Assert;
import org.junit.Test;

public abstract class JavaModelQueryTestCase<T extends EObject, R> extends ModiscoTestCase 
{
	abstract protected IJavaModelQuery<T, R> instanciateQuery();
	
	@Test
	final public void testEvaluateNullContext() throws ModelQueryExecutionException
	{
		testEvaluateContext(null, null);
	}
	
	final protected void testEvaluateContext(final T context, final R expectedResult) throws ModelQueryExecutionException
	{
		IJavaModelQuery<T, R> query = instanciateQuery();
		final R actualResult = query.evaluate(context, null);
		Assert.assertEquals(expectedResult, actualResult);
	}
	
}
